From: Alessandro Bono Date: Thu, 30 Oct 2025 10:47:17 +0000 (+0100) Subject: loginManager: Use systemd session auto object to get session ID X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~44^2~148 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5db3a2b7bcfebdcc71038df890ae44308c98b95e;p=gnome-shell.git loginManager: Use systemd session auto object to get session ID Relying on the Display property is buggy when the gdm user spawns more than one gnome-shell instance. ``` $ loginctl SESSION UID USER SEAT LEADER CLASS TTY IDLE SINCE 11 42 gdm - 11778 manager-early - no - c20 42 gdm seat0 34313 greeter tty1 yes 17h ago c21 42 gdm - 34938 greeter - no - c22 42 gdm - 35693 greeter - no - ``` From the logs: ``` $ journalctl -b | grep "Will monitor" [...] Oct 29 15:14:59 gnome-shell[34961]: Will monitor session c20 Oct 29 15:22:57 gnome-shell[35716]: Will monitor session c20 Oct 29 15:22:58 gnome-shell[35716]: Will monitor session c20 ``` Use the systemd session auto object for getting the session id. We can't return directly the session proxy created from it because it won't emit signals. From the documentation[1]: ``` Signals are only emitted on objects referencing a specific session ID not on the "/org/freedesktop/login1/session/self" or "/org/freedesktop/login1/session/auto" convenience objects, as they can only be dereferenced relative to a method caller. ``` [1] https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.login1.html Part-of: --- diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js index 86f17479e..a93e0cb5d 100644 --- a/js/misc/loginManager.js +++ b/js/misc/loginManager.js @@ -127,33 +127,17 @@ class LoginManagerSystemd extends Signals.EventEmitter { let sessionId = GLib.getenv('XDG_SESSION_ID'); if (!sessionId) { log('Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly.'); - const userProxy = await this.getCurrentUserProxy(); - let [session, objectPath] = userProxy.Display; - if (session) { - log(`Will monitor session ${session}`); - sessionId = session; - } else { - log('Failed to find "Display" session; are we the greeter?'); - - for ([session, objectPath] of userProxy.Sessions) { - const sessionProxy = new SystemdLoginSession(Gio.DBus.system, - 'org.freedesktop.login1', - objectPath); - log(`Considering ${session}, class=${sessionProxy.Class}`); - if (sessionProxy.Class === 'greeter') { - log(`Yes, will monitor session ${session}`); - sessionId = session; - break; - } - } - - if (!sessionId) { - log('No, failed to get session from logind.'); - return null; - } + try { + const autoSession = await SystemdLoginSession.newAsync( + Gio.DBus.system, 'org.freedesktop.login1', '/org/freedesktop/login1/session/auto'); + sessionId = autoSession.Id; + } catch (error) { + logError(error, 'Failed to get session from logind'); + return null; } } + log(`Will monitor session ${sessionId}`); try { const [objectPath] = await this._proxy.GetSessionAsync(sessionId); this._currentSession = await SystemdLoginSession.newAsync(